<template>
	<view class="pages-user-login" v-if="isLoad">
		<view class="flex-center flex-column" style="height: 100vh">
			<block v-if="!configInfo.plugAuth.agentport">
				<abnor type="NOT_AUTH" :isCenter="true"></abnor>
			</block>
			<block v-if="configInfo.plugAuth.agentport">
				<view style="height: 80rpx;"></view>
				<view @tap.stop="$util.goUrl({url:`/agent/pages/account/login?agent=1`})"
					class="login-btn wechat flex-center f-title c-base radius" :style="{ background: primaryColor}"><i
						class="iconfont iconhexiaoren mr-md"></i>我是{{$t('action.agentName')}}</view>
				<view @tap.stop="$util.goUrl({url:`/agent/pages/account/login`})"
					class="login-btn phone flex-center f-title c-base radius"
					:style="{ borderColor: primaryColor,color:primaryColor}"><i
						class="iconfont icondailishangduan_1 mr-md"></i>我是管理员</view>
				<view style="height: 120rpx;"></view>
				<!-- #ifdef MP-WEIXIN-AGENT -->
				<view class="f-caption c-warning fix" style="width:calc(100% - 60rpx);bottom:30rpx">
					{{detail.agent_login_text}}
					<view class="space-safe"></view>
				</view>
				<!-- #endif -->
				<!-- #ifdef APP-PLUS -->
				<view class="f-caption c-warning fix" style="width:calc(100% - 60rpx);bottom:30rpx"
					v-if="is_app_user==3">
					{{detail.agent_login_text}}
					<view class="space-safe"></view>
				</view>
				<!-- #endif -->
			</block>
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapActions,
		mapMutations
	} from 'vuex';
	import siteInfo from '@/siteinfo.js';
	export default {
		components: {},
		data() {
			return {
				isLoad: false,
				detail: {},
			}
		},
		async onLoad(options) {
			if (!this.configInfo.id) {
				await this.getConfigInfo()
			}
			// #ifdef MP-WEIXIN-AGENT
			this.detail = await this.$api.base.getConfig()
			// #endif
			// #ifdef APP-PLUS
			if (this.is_app_user == 3) {
				this.detail = await this.$api.base.getConfig()
			}
			// #endif
			let {
				userInfo
			} = this
			if (!this.isLoad && (!userInfo || (userInfo && !userInfo.id))) {
				this.updateUserItem({
					key: 'isGzhLogin',
					val: false
				})
			}
			this.lockTap = false
			this.isLoad = true
			// #ifdef H5
			this.$jweixin.initJssdk(() => {
				this.toAppShare()
			})
			// #endif
		},
		onShareAppMessage() {
			return {
				title: '选择身份',
				imageUrl: '',
				path: `/agent/pages/login`
			}
		},
		computed: mapState({
			configInfo: state => state.config.configInfo,
		}),
		methods: {
			...mapActions(['getConfigInfo']),
			...mapMutations(['updateUserItem']),
			toAppShare() {
				let {
					siteroot
				} = siteInfo
				let url = siteroot.split('/index.php')[0]
				let port = ''
				// #ifdef H5-AGENT
				port = 'agent/'
				// #endif
				// #ifdef APP-PLUS
				port = this.is_app_user === 1 ? '' : 'agent/'
				// #endif
				let href = `${url}/${port}${this.portName}/?#/agent/pages/login`
				let title = '选择身份'
				let summary = ''
				let imageUrl = ''
				// #ifdef H5
				this.$jweixin.showOptionMenu()
				this.$jweixin.shareAppMessage(title, summary, href, imageUrl)
				this.$jweixin.shareTimelineMessage(title, href, imageUrl)
				// #endif
				// #ifdef APP-PLUS
				uni.share({
					provider: "weixin",
					scene: 'WXSceneSession',
					type: 0,
					href,
					title,
					summary,
					imageUrl,
					success: function(res) {
						console.log("success:" + JSON.stringify(res));
					},
					fail: function(err) {
						console.log("fail:" + JSON.stringify(err));
					}
				});
				// #endif
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: #fff;
		height: 100%;
	}

	.pages-user-login {


		.logo-img {
			width: 160rpx;
			height: 160rpx;
		}



		.login-btn {
			width: 220pt;
			height: 44pt;
			font-size: 13pt;
			border: 1rpx solid #000;
			transform: rotateZ(360deg);
			margin-top: 40rpx;

			.iconfont {
				font-size: 19pt;
			}
		}

		.wechat {
			border: none;
			box-shadow: 0 18rpx 9rpx 0 rgba(0, 188, 82, 0.07);
		}

		.apple {
			font-size: 15pt;
		}

		.banner-info {
			width: 100%;

			.banner-img {
				width: 100%;
				height: 100%;
			}

			.swiper-to-home {
				width: 122rpx;
				height: 47rpx;
				z-index: 999;
				right: 40rpx;
				top: 80rpx;
				background: rgba(0, 0, 0, 0.3);
			}
		}
	}
</style>